package com.gz.mylife.app;

import java.util.List;

import android.content.Context;

import com.zl.smartmall.library.IGZAddress;
import com.zl.smartmall.library.concurrent.ThreadExecutor;
import com.zl.smartmall.library.listener.GetMyCommunityAddressListener;
import com.zl.smartmall.library.po.GZCommunityInfo;
import com.zl.smartmall.library.vo.GZCommunityInfoDAO;

public class LoadCommunityManager {
	private Context mContext;

	public LoadCommunityManager(Context cxt) {
		this.mContext = cxt;
	}

	public void getCommunitys() {
		IGZAddress.getInstance().getMyCommunity(new MyGetCommunityListener());
	}

	private class MyGetCommunityListener extends GetMyCommunityAddressListener {

		@Override
		public void onResponseSuccess(final List<GZCommunityInfo> lists) {
			ThreadExecutor.getInstance().execute(new Runnable() {

				@Override
				public void run() {
					GZCommunityInfoDAO.DeleteAll(mContext);
					GZCommunityInfoDAO.saveAll(mContext, lists);
				}
			});
		}

		@Override
		public void onNoMoreData() {

		}

		@Override
		public void onNoNetWork() {

		}

		@Override
		public void onOffline() {

		}

		@Override
		public void onResponseFailed() {

		}

	}
}
